POV-Ray : Newsgroups : povray.programming : HF height: bug report : Re: HF height: bug report Server Time
6 Oct 2024 16:18:18 EDT (-0400)
  Re: HF height: bug report  
From: Vadim Sytnikov
Date: 6 Aug 2001 14:11:43
Message: <3b6edddf$1@news.povray.org>
Ah, well, well... Thorsten, take this:

How are you going to *reliably* save and restore your data?
In programs made with different compilers (let alone on different
platforms)? (Please don't say "I don't want to save my data!"
You do. And please don't resort to indexing or other tricks).

There is a known way of doing this for integer values: write
byte-by-byte, then restore byte-by-byte (doing proper shifts
and additions); POV-Ray does exactly that when, say,
loads tga files.

Save your 'long' with multibyte constant (by whatever method),
then just recompile your program with different compiler, then
load your 'long' back. There is *absolutely* NO guarantee that
the following, or anything you could devise, will work:

  enum my_enum_t { MY_MB = 'ab'; };

  long my_long = MY_MB;

  if( must_save )
  {
     // PART1: save by whatever method
  }
  if( must_load )
  {
    // PART2: load by whatever method
  }
  if( my_long != MY_MB ) { /* shit happens... */ }

If PART1 is executed in the program compiled with one
compiler, and PART2 -- in that same program but compiled
with another compiler, then you *will* get into the last set
of curly braces sooner or later.

We all know Microsoft's attitude to portability, and yet
their exists the MKFOURCC() macro. Guess why.

"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:3b6ed53e@news.povray.org...
> In article <3b6e92ae$1@news.povray.org> , "Vadim Sytnikov"
<syt### [at] rucom>
> wrote:
>
> > While 'ab' may be translated into 0x00006261, or 0x00006162,
> > or god knows what. The Standard does not define that.
>
> And what is wrong with this???  Why would I even care about the integer
> value?  Simple: In a properly written program, I do not (see below)!
>
> > Somebody has pointed out that using multicharacter constants
> > would be OK in enums... Not quite so.
>
> Quite so.  It works very well and is widely used (examples: TIFF, TrueType
> fonts, Mac OS, Windows, etc).  Please don't make a problem out of
something
> where there is _none_ and has never been in the past two decades except in
> the minds of the writers of a certain compiler who seem to have been
locked
> in their ivory tower for too long ;-)
>
> > for equality; you cannot tell which is bigger and which is smaller.
>
> As I said:
>
> >> doing a comparison like 'abcd' > 1234 it is at least very bad style
(nearly
> programming error).  [...]  after all comparing an enumeration value
against
> an integer constant is bad style. <<
>
>     Thorsten
>
> ____________________________________________________
> Thorsten Froehlich, Duisburg, Germany
> e-mail: tho### [at] trfde
>
> Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.